import 'package:flutter/material.dart';
import 'package:provide/provide.dart';
import 'package:flutter_shop/provide/details_info.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class DetailsTopArea extends StatelessWidget {
  const DetailsTopArea({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Provide<DetailsInfoProvide>(
      builder: (context,child,val){
        var goodsinfo=Provide.value<DetailsInfoProvide>(context).goodsinfo.data.goodInfo;
        if(goodsinfo!=null){
          return Container(
            color: Colors.white,
            child: Column(
              children: <Widget>[
                _goodsImage(goodsinfo.image1),
                _goodsName(goodsinfo.goodsName),
                _goodsNum(goodsinfo.goodsSerialNumber),
                  _goodsPrice(goodsinfo.presentPrice,goodsinfo.oriPrice)
              ],
            ),
          );
        }else{
          return Text('正在加载中....');
        }
      }
    );
  }
  //商品图片
  Widget _goodsImage(url){
    return Image.network(
      url,
      width: ScreenUtil().setWidth(740),
      );
  }
  //商品名称
  Widget _goodsName(name){
    return Container(
      width: ScreenUtil().setWidth(740),
      padding: EdgeInsets.only(left: 15),
      child: Text(
        name,
        style: TextStyle(
          fontSize: ScreenUtil().setSp(30)
        ),
      ),
    );
  }
  //商品编号
  Widget _goodsNum(num){
    return Container(
      width: ScreenUtil().setWidth(740),
      padding: EdgeInsets.only(left: 15),
      margin: EdgeInsets.only(top: 8),
      child: Text(
        '编号：${num}',
        style: TextStyle(
          color: Colors.black12
        ),
      ),
    );
  }
//商品价格方法

  Widget _goodsPrice(presentPrice,oriPrice){

    return  Container(
      width: ScreenUtil().setWidth(730),
      padding: EdgeInsets.only(left:15.0),
      margin: EdgeInsets.only(top:8.0),
      child: Row(
        children: <Widget>[
          Text(
            '￥${presentPrice}',
            style: TextStyle(
              color:Colors.pinkAccent,
              fontSize: ScreenUtil().setSp(40),

            ),

          ),
          Text(
            '市场价:￥${oriPrice}',
            style: TextStyle(
              color: Colors.black26,
              decoration: TextDecoration.lineThrough
            ),
                
            
            )
        ],
      ),
    );

   }
  // 商品价格
  // Widget _goodsPrice(presentPrice,oriPrice){
  //   return Container(
  //     width: ScreenUtil().scaleWidth(730),
  //     padding: EdgeInsets.only(left: 15.0),
  //     margin: EdgeInsets.only(top:8.0),
  //     child: Row(
  //       children: <Widget>[
  //         Text(
  //           '￥${presentPrice}',
  //           style: TextStyle(
  //             color: Colors.red,
  //             fontSize: ScreenUtil().setSp(40)
  //           ),
  //         ),
  //         Text(
  //           '市场价：￥${oriPrice}',
  //           style: TextStyle(
  //             color: Colors.black12,
  //             fontSize: ScreenUtil().setSp(30),
  //             decoration: TextDecoration.lineThrough
  //           ),
  //         ),
  //       ],
  //     ),
  //   );
  // }
}